import { TokenData, parse, compile, match, pathToRegexp, stringify } from 'path-to-regexp'


// console.log(regexp,keys);
const path = '/user/:name/:id';
const url = '/user/liyunfei/3'

/* function getParamsByDymacRoute(url, path) {
  const { regexp, keys } = pathToRegexp(path);
  let parmas = null
  if (regexp.test(url)) {
    parmas = {}
    const matchRes = url.match(regexp)//regexp.exec(url)
    keys.map((item, index) => {
      parmas[item.name] = matchRes[index + 1]
    })
  }
  return parmas
}
console.log(getParamsByDymacRoute(url, path)) */
console.log(match(path)(url))
// console.log(compile(path)({name:'abc',id:'4'}))
